<template>
	<view>
		<view class="taber">
			<block v-for="(item,index) in list" :key="index">
				<navigator v-if="item.jump" class="item" :url="item.path" open-type="switchTab" @click="jump(item)">
					<image :src="selectindex==index? item.selectedIconPath: item.iconPath" mode=""></image>
					<view :class="selectindex==index? 'text Select': 'text noSelect'">
						{{item.text}}
					</view>
				</navigator>
				<view v-else class="item center" @click="jump(item)">
					<image @click="open()" :src="selectindex==index? item.selectedIconPath: item.iconPath" mode=""></image>


				</view>
			</block>
		</view>
		<uni-popup ref="popup" type="bottom" maskClick>
			<uni-card>
				<view class="submit" @click="gosubmit">
					上报困人
				</view>
				<view class="fault" @click="gofault">
					上报故障
				</view>
			</uni-card>
			<uni-card>
				<view class="cancel" :before-close="true" @close="close">
					取消
				</view>
			</uni-card>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	export default {
		components: {
			uniPopup,
			uniPopupMessage,
			uniPopupDialog
		},
		props: ["select"],
		data() {
			return {
				selectindex: 0,
				list: [{
						id: 0,
						selectedIconPath: require("static/img/tabbar/home01.png"),
						iconPath: require("static/img/tabbar/home02.png"),
						text: "首页",
						path: "/pages/tabbar/home/home",
						jump: true
					},
					{
						id: 1,
						selectedIconPath: require("static/img/tabbar/polling01.png"),
						iconPath: require("static/img/tabbar/polling02.png"),
						text: "巡检",
						path: "/pages/tabbar/polling/polling",
						jump: true
					},
					{
						id: 2,
						selectedIconPath: require("static/img/tabbar/center.png"),
						iconPath: require("static/img/tabbar/center.png"),
						text: "",
						jump: false,
						path: "/pages/tabbar/center/center",
					},
					{
						id: 3,
						selectedIconPath: require("static/img/tabbar/work01.png"),
						iconPath: require("static/img/tabbar/woek02.png"),
						text: "工作",
						jump: true,
						path: "/pages/tabbar/work/work",
					},
					{
						id: 4,
						selectedIconPath: require("static/img/tabbar/mine01.png"),
						iconPath: require("static/img/tabbar/mine02.png"),
						text: "我的",
						jump: true,
						path: "/pages/tabbar/mine/mine",
					}
				]
			}
		},
		computed: {

		},
		created() {
			this.selectindex = this.select
		},
		methods: {
			jump(data) {
				if (data.jump) {
					if (data.id == this.selectindex) return
					uni.reLaunch({
						url: data.path
					})
					console.log(data.path, "要跳转了")
					this.selectindex = data.id
				} else {
					this.$refs.popup.open()
					console.log(this.$refs, '打开旷课')
				}

			},
			open(){},
			// 取消
			 close(done){
				done()
			},
			// 上报困人 跳转
			gosubmit(){
				uni.navigateTo({
					url:"/pages/tabbar/polling/submit/submit"
				})
			},
			gofault(){
				uni.navigateTo({
					url:"/pages/tabbar/polling/fault/fault"
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	uni-view {
		line-height: 1.3;
	}

	.taber {
		width: 100%;
		height: 98rpx;
		border-top: 1rpx solid rgba(30, 31, 31, .1);
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		z-index: 2;
		display: flex;
		justify-content: space-around;
		align-items: center;

		.item {
			width: calc(100% / 5);
			text-align: center;

			image {
				width: 40rpx;
				height: 40rpx;
				margin-top: 16rpx;
			}

			.text {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				font-weight: 400;
			}

			.noSelect {
				color: #ADB5C5;
			}

			.Select {
				color: #017EFE;
			}

			&:nth-child(3) {
				image {
					width: 101rpx;
					height: 114rpx;
					margin-bottom: 50rpx;
				}
			}
		}

		.center {

			image {
				width: 101rpx;
				height: 114rpx;
			}
		}
	}
	.uni-card:nth-child(1){
		width: 670rpx;
		height: 208rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border-radius: 16rpx;
		margin: 0 auto;
		view{
			text-align: center;
			line-height: 80rpx;
			// height: 29rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #017EFE;
		}
	}
	.submit{
		border-bottom: 1px solid #E2E6EF;
	}
	.uni-card:nth-child(2){
		width: 670rpx;
		height: 104rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border-radius: 16rpx;
		margin: 0 auto;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		view{
			text-align: center;
			line-height: 75rpx;
			// height: 29rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #34363D;
		}
	}
</style>
